NotEmptyList
@Serializable(with = NotEmptyListSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
Represents a list that has at least one element of type E.
You can use the notEmptyListOf or the toNotEmptyList functions for creating an instance of this type.
Serialization and deserialization
The serialization and deserialization processes of this type behave like for the List type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
val string: NotEmptyList<Int> = notEmptyListOf(1, 2, 3)
val encoded: String = Json.encodeToString(string)
println(encoded) // [1,2,3]
val decoded: NotEmptyList<Int> = Json.decodeFromString(encoded)
println(decoded == string) // true
Content copied to clipboard
Types
Link copied to clipboard
object Companion
Contains static declarations for the NotEmptyList type.